﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Model = AzureGames.Model.Board;

namespace AzureGames.Domain.Models
{
    public class ActiveGame
    {
        public ActiveGame(Model.Board board, List<GamePlayer> players)
        {
            BoardID = board.ID;
            GameDefinitionID = board.GameDefinitionID;
            Name = BuildName(players);
            Value = board.Value;
            GamePlayers = players;
            State = board.State.ToString();
            LastUpdatedDate = board.LastUpdatedDate.ToString("yyyy-MM-ddThh:mm:ss");
        }

        private string BuildName(List<GamePlayer> players)
        {
            if(players.Count==2)
                return players[0].Name + " vs " + players[1].Name;

            return string.Format("{0} player game", players.Count);
        }

        public Guid BoardID { get; set; }
        public int GameDefinitionID { get; set; }
        public long Value { get; set; }
        public List<GamePlayer> GamePlayers { get; set; }
        public string State { get; set; }
        public string LastUpdatedDate { get; set; }
        public string Name { get; set; }
    }
}
